<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['banner']=$basic['image'];
$return['basic']=$basic;
if($_RQ['op']=='main'){
	set_html('title','审核作品');
	$return['sum']=pdo_count('jy_quanhuo_item',array('uniacid'=>$_SESSION['uniacid'],'status'=>0),'id');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$return['params']=array();
	//$opusall=pdo_getall('jy_quanhuo_item',array('uniacid'=>$_SESSION['uniacid'],'status'=>0));
	//foreach($opusall as &$row){
		//$row['isvip']=pdo_getcolumn('jy_quanhuo_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$row['mid']),'isvip');
	//}
	//paixu($opusall,'isvip','desc');
	//获取所有待审核的作品
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$page =intval($_RQ['page']) ? intval($_RQ['page']) : 1;
	//$start = ($page-1)*$psize;
	//$list=array_slice($opusall,$start,10);
	//是否管理员
	if($basic['sysmid']){
		foreach($basic['sysmid'] as &$v){
			if($v['mid'] == $_SESSION['uid']){
				$kefu =true;
			}
		}
	}
	$isboss=pdo_count('jy_quanhuo_sns',array('uniacid'=>$_SESSION['uniacid'],'bossmid'=>$_SESSION['uid']),'id');
	if($kefu){
		$list=pdo_getslice('jy_quanhuo_item',array('uniacid'=>$_SESSION['uniacid'],'status'=>0),array($pindex,$psize),$total,$fields,'','id asc');
	}elseif($isboss>0 && $basic['issns']){
		$snsids=pdo_getall('jy_quanhuo_sns',array('uniacid'=>$_SESSION['uniacid'],'bossmid'=>$_SESSION['uid']),'id','id');
		$snsids=array_keys($snsids);
		$list=pdo_getslice('jy_quanhuo_item',array('uniacid'=>$_SESSION['uniacid'],'status'=>0,'snsid'=>$snsids),array($pindex,$psize),$total,$fields,'','id asc');
	}else{
		$list=array();
	}
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			$item['member']=pdo_get('core_members',array('id'=>$item['mid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','avatar','nickname'));
		}
	}
	$return['list']=$list;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='pass'){
	$postdata=get_postdata();
	if(!$postdata['id']){
		exi('没有找到该作品，请重新选择！','error');
	}
	pdo_update('jy_quanhuo_item',array('status'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['id']));
	$return['ok']=1;
	exi($return);
}
if($_RQ['op']=='unpass'){
	$postdata=get_postdata();
	if(!$postdata['id']){
		exi('没有找到该作品，请重新选择！','error');
	}
	pdo_update('jy_quanhuo_item',array('status'=>2),array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['id']));
	$return['ok']=1;
	exi($return);
}

